#
# Testing
#

# Setup the variables we use below.
set(FEM_TESTS
  Vector_test.cpp
  Matrix_test.cpp
  Array_test.cpp)

if(GTEST_FOUND)
  enable_testing()
  include_directories(${GTEST_INCLUDE_DIRS})
  foreach(TEST ${FEM_TESTS})
    string(REGEX REPLACE "\\.(cc|cxx|cpp)" "" TEST_NAME ${TEST})
    # string(REPLACE "test/" "" TEST_NAME ${TEST_NAME})
    set(TEST_SOURCE ${TEST})
    add_executable(${TEST_NAME} ${TEST_SOURCE})
    set_target_properties(${TEST_NAME} PROPERTIES
      RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/test")
    target_link_libraries(${TEST_NAME} FEM
      ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})
    add_test(${TEST_NAME} ${TEST_NAME})
  endforeach(TEST)
endif(GTEST_FOUND)